package com.crm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crm.entity.Netfollows;
import com.crm.service.NetfollowsService;
import com.crm.utils.PageUtil;
import com.crm.utils.ResponeMessageUtil;
import com.crm.utils.UUIDUtil;

/**
 * 跟踪管理Controller
 */
@RestController
@RequestMapping("/netfollows")
public class NetfollowsController {

	@Autowired
	private NetfollowsService netfollowsService;
	
	/**
	 * 多条件查询跟踪信息
	 * @param limit
	 * @param page
	 * @param stduentname
	 * @param followtime
	 * @param followstate
	 * @return
	 */
	@RequestMapping("/selectNetfollowsAll")
	public ResponeMessageUtil selectNetfollowsAll(Integer limit,Integer page,String userid,String stduentname,String followtime, String endDate,String followstate) {
		int setValue = PageUtil.getSetValue(page, limit);
		return ResponeMessageUtil.ok(netfollowsService.getCount(null,stduentname, followtime, endDate, followstate), netfollowsService.selectAll(limit, setValue, null, stduentname, followtime, endDate, followstate));
	}
	
	/**
	 * 多条件查询跟踪信息
	 * @param limit
	 * @param page
	 * @param userid
	 * @param stduentname
	 * @param followtime
	 * @param followstate
	 * @return
	 */
	@RequestMapping("/selectNetfollowsIdAll")
	public ResponeMessageUtil selectNetfollowsIdAll(Integer limit,Integer page,String userid,String stduentname,String followtime, String endDate,String followstate) {
		int setValue = PageUtil.getSetValue(page, limit);
		return ResponeMessageUtil.ok(netfollowsService.getCount(userid,stduentname, followtime, endDate, followstate), netfollowsService.selectAll(limit, setValue, userid, stduentname, followtime, endDate, followstate));
	}
	
	/**
	 * 根据id删除跟踪信息
	 * @param id
	 * @return
	 */
	@RequestMapping("/deleteNetfollows")
	public boolean deleteNetfollows(String id) {
		return netfollowsService.deleteByPrimaryKey(id)>0?true:false;
	}
	
	/**
	 * 根据id修改跟踪信息
	 * @param netfollows
	 * @return
	 */
	@RequestMapping("/updateNetfollows")
	public boolean updateNetfollows(Netfollows netfollows) {
		return netfollowsService.update(netfollows)>0?true:false;
	}
	
	/**
	 * 添加跟踪信息
	 * @param netfollows
	 * @return
	 */
	@RequestMapping("/createNetfollows")
	public boolean createNetfollows(Netfollows netfollows,String name) {
		netfollows.setStduentname(name);
		netfollows.setId(UUIDUtil.getUUID());
		return netfollowsService.insert(netfollows)>0?true:false;
	}
}
